﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AutoLog
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load( object sender, EventArgs e )
        {
            // TODO: This line of code loads data into the 'dsVehicles.Vehicle' table. You can move, or remove it, as needed.
            this.vehicleTableAdapter.Fill( this.dsVehicles.Vehicle );

        }

        private void dgvVehicles_CellContentClick( object sender, DataGridViewCellEventArgs e )
        {

        }

        private void btnAddVehicle_Click( object sender, EventArgs e )
        {
            string vin;
            string model;
            string make;
            string name;
            uint owner;
            uint year;
            AddVehicle av = new AddVehicle();
            if ( av.ShowDialog() == System.Windows.Forms.DialogResult.OK )
            {
                vin = ( (TextBox)av.Controls.Find( "tbVIN", true )[ 0 ] ).Text;
                make = ( (TextBox)av.Controls.Find( "tbMake", true )[ 0 ] ).Text;
                model = ( (TextBox)av.Controls.Find( "tbModel", true )[ 0 ] ).Text;
                name = ( (TextBox)av.Controls.Find( "tbName", true )[ 0 ] ).Text;
                year = (uint)( (NumericUpDown)av.Controls.Find( "nudYear", true )[ 0 ] ).Value;
                owner = (uint)( (ComboBox)av.Controls.Find( "cbOwner", true )[ 0 ] ).SelectedValue;
                MessageBox.Show( "Name: " + name + "\n" +
                                "Make: " + make + "\n" +
                                "Model: " + model + "\n" +
                                "Year: " + year + "\n" +
                                "VIN: " + vin + "\n" +
                                "Owner: " + owner);
            }
        }
    }
}